package com.system.FinancialDepartment.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;


import com.system.FinancialDepartment.entity.RewardAndPunishiment;

@org.springframework.stereotype.Repository
public interface RewardAndPunishimentRepository extends PagingAndSortingRepository<RewardAndPunishiment,Long>,JpaSpecificationExecutor<RewardAndPunishiment>{
	//1.通过解析方法名创建查询
   	public RewardAndPunishiment findById(Long id);  	

   	@Modifying 
   	@Query(value="update RewardAndPunishiment rap set rap.empId = ?2,rap.event = ?3,rap.time = ?4,rap.score = ?5 where rap.id = ?1") 
   	public int updateRewardAndPunishiment(Long id,Long empId,String event,Date time,Long score);
   	
   	@Modifying 
   	@Query(value="delete RewardAndPunishiment rap where rap.id  in (:ids)") 
   	public int deleteRewardAndPunishiments(@Param("ids")Long[] ids);
   	
   	@Query(value="from RewardAndPunishiment rap where rap.empId like ?1") 
   	public Page<RewardAndPunishiment> findAll(Long empId ,Pageable pageable);

   	@Query(value="from RewardAndPunishiment rap where rap.id like ?1") 
	public List<RewardAndPunishiment> findAll(Long empId);

}
